<template>
    <div class="app-container project-operate-container">
        <div v-if="opt != 'add'">
            <el-descriptions title="">
                <el-descriptions-item label="序号">
                    <el-tag size="medium">{{ obj != null ? obj.index : index }}</el-tag>
                </el-descriptions-item>
            </el-descriptions>
        </div>

        <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="项目信息" name="first">
                <el-form :model="form" ref="form" :rules="rules" label-width="100px">
                    <!-- <el-row>
                        <el-col :span="8">
                            <el-form-item label="主分类" prop="classificationId" label-width="110px">
                                <treeselect v-model="form.classificationId" :options="optionData" placeholder="请选择主分类"
                                    :disabled="opt == 'details'" style="width: 325px" />
                            </el-form-item>
                        </el-col>
                    </el-row> -->
                    <el-row>
                        <el-col :span="6">
                            <el-form-item label="立项方式" label-width="110px">
                                <el-radio v-model="radio" :disabled="opt == 'details'" label="1"
                                    @change="handleRadioChange('1')">合同</el-radio>
                                <el-radio v-model="radio" :disabled="opt == 'details'" label="2"
                                    @change="handleRadioChange('2')">产品</el-radio>
                            </el-form-item>
                        </el-col>
                        <el-col :span="2" v-show="typeShow">
                            <el-button style="margin-top:5px" type="primary" size="mini" @click="selectContract"
                                v-if="opt != 'details'">选择合同</el-button>

                        </el-col>
                        <el-col :span="2">
                            <el-button style="margin-top:5px" type="primary" size="mini" @click="selectProduct"
                                v-if="opt != 'details'">选择产品</el-button>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8" v-show="typeShow">
                            <el-form-item label="合同名称" prop="contractName" label-width="110px">
                                <el-input v-model="form.contractName" disabled="true" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="16" v-show="typeShow">
                            <el-form-item label="客户名称" prop="enterpriseName" label-width="110px">
                                <el-input v-model="form.enterpriseName" disabled="true" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24" v-show="typeShow2">
                            <el-form-item label="客户名称" prop="enterpriseName" label-width="110px">
                                <el-input v-model="form.enterpriseName" :disabled="opt == 'details'"
                                    :readonly="readonly" @focus="enterprise" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="6">
                            <el-form-item label="项目编号" prop="projectNumber" label-width="110px">
                                <el-input v-model="form.projectNumber" placeholder="请输入项目编号"
                                    :disabled="opt == 'details'" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="2">
                            <el-button style="margin-top:5px;margin-left:20px" type="primary" size="mini"
                                @click="selectProjectAll" :disabled="opt == 'details'">项目查看</el-button>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="项目名称" prop="projectName" label-width="110px">
                                <el-input v-model="form.projectName" placeholder="请输入项目名称"
                                    :disabled="opt == 'details'" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="项目负责人" prop="projectLeader" label-width="110px">
                                <el-input v-model="form.projectLeader" :disabled="opt == 'details'"
                                    placeholder="请选择项目负责人" @focus="selectOpen(1)" :readonly="readonly" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="计划开始时间" prop="startTime" label-width="110px">
                                <el-date-picker clearable :disabled="opt == 'details'" style="width: 292px"
                                    v-model="form.startTime" type="date" value-format="yyyy-MM-dd"
                                    placeholder="请选择计划开始时间">
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="计划结束时间" prop="endTime" label-width="110px">
                                <el-date-picker clearable :disabled="opt == 'details'" style="width: 292px"
                                    v-model="form.endTime" type="date" value-format="yyyy-MM-dd"
                                    placeholder="请选择计划结束时间">
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="咨询差旅费" prop="consultAmount" label-width="110px">
                                <el-input v-model="form.consultAmount" placeholder="请输入咨询差旅费"
                                    :disabled="opt == 'details'" :maxlength="12"/>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>

                        <el-col :span="8">
                            <el-form-item label="其他费用" prop="elseAmount" label-width="110px">
                                <el-input v-model="form.elseAmount" placeholder="请输入其他费用"
                                    :disabled="opt == 'details'" :maxlength="12"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="创建人" prop="creationName" label-width="110px">
                                <el-input v-model="form.creationName" placeholder="请输入创建人" disabled="true" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="创建时间" prop="creationTime" label-width="110px">
                                <el-input v-model="form.creationTime" disabled="true" />
                            </el-form-item>
                        </el-col>
                    </el-row>

                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="备注" prop="node" label-width="110px">
                                <el-input :maxlength="2000" show-word-limit v-model="form.node" placeholder="请输入备注"
                                    type="textarea" :autosize="{ minRows: 3, maxRows: 4 }"
                                    :disabled="opt == 'details'" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row style="margin: 10px -10px 12px 40px;width:1169px">
                        <el-row :gutter="10" class="mb8">
                            <el-col :span="1.5">
                                <span style="font-size: 14px;margin: 0px 5px 0px 550px;">收款方式 </span>&nbsp;&nbsp;
                                <el-button type="primary" plain icon="el-icon-plus" size="mini"
                                    @click="addProjectPayment" style="text-align: center;"
                                    v-if="opt != 'details'"></el-button>
                            </el-col>
                        </el-row>
                        <el-table v-loading="loading" :data="tableData" size="mini" border>
                            <el-table-column label="序号" type="index" align="center" prop="indexTwo" />
                            <el-table-column prop="paymentName" label="款项名称" min-width="120" align="center">
                                <template slot-scope="scope">
                                    <el-input maxlength="50" v-model="scope.row.paymentName"
                                        :disabled="opt == 'details'" />
                                </template>
                            </el-table-column>
                            <el-table-column prop="amountCollected" label="收款金额" min-width="80" align="center">

                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.amountCollected" :disabled="opt == 'details'" maxlength="12"/>
                                </template>
                            </el-table-column>
                            <el-table-column prop="estimatedCollectionTime" label="预计收款时间" min-width="72"
                                align="center">

                                <template slot-scope="scope">
                                    <el-date-picker clearable v-model="scope.row.estimatedCollectionTime" type="date"
                                        value-format="yyyy-MM-dd" :picker-options="{ disabledDate: dateOptions }"
                                        placeholder="请选择预计收款时间" :disabled="opt == 'details'">
                                    </el-date-picker>
                                </template>
                            </el-table-column>
                            <el-table-column fixed="right" label="操作" min-width="40" align="center"
                                v-if="opt != 'details'">

                                <template slot-scope="scope">
                                    <el-button size="mini" type="text" icon="el-icon-delete"
                                        @click="delContractListInfo(scope.row)" title="删除"></el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-row>
                    <el-row style="margin: 50px -10px 12px 40px;width:1169px">
                        <el-row :gutter="10" class="mb8">
                            <el-col>
                                <span style="font-size: 14px;margin: 25px 50px 25px 550px;">产品信息</span>
                            </el-col>
                        </el-row>
                        <el-table v-loading="loading" :data="productInfoList" size="mini" height="300"
                            :row-style="{ height: '30px' }" border :cell-style="{ padding: '0px' }">
                            <el-table-column label="序号" type="index" align="center" :index="indexMethodList" />
                            <el-table-column label="产品类型" align="center" prop="productCategory">

                                <template slot-scope="scope">
                                    <dict-tag :options="dict.type.product_type" :value="scope.row.productCategory" />
                                </template>
                            </el-table-column>
                            <el-table-column label="产品编号" align="center" prop="productNumber" />
                            <el-table-column label="产品名称" align="center" prop="productName" />
                            <el-table-column label="费用" align="center" prop="pricingRange" v-if="radio == '2'">
                                <template slot-scope="scope">
                                    <el-button v-if="isBtn" @click.stop="addFees(scope.row)" size="small" type="text"
                                        :class="{ 'cancel-class': scope.row.pricingRange === '0' }">{{
            scope.row.pricingRange }}</el-button>
                                    <el-button v-else size="small" type="text">{{
            scope.row.pricingRange }}</el-button>
                                </template>
                            </el-table-column>
                            <el-table-column label="费用" align="center" prop="pricingRange" v-else />

                            <el-table-column label="操作" align="center" class-name="small-padding fixed-width"
                                v-if="opt != 'details'">

                                <template slot-scope="scope">
                                    <el-button size="mini" type="text" icon="el-icon-delete"
                                        @click="handleDeleteProduct(scope.row)" title="删除"></el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                        <pagination v-show="total > 0" :total="total" :page.sync="queryProductListParams.pageNum"
                            :limit.sync="queryProductListParams.pageSize" @pagination="getProjectProductList" />
                    </el-row>

                    <!-- 资质产品选择界面 -->
                    <el-dialog :title="titleProduct" :visible.sync="openProduct" width="1000px" append-to-body>
                        <el-row>
                            <el-col :span="24">
                                <el-form :model="queryProductParams" ref="queryProductForm" size="small" :inline="true"
                                    v-show="showSearch" label-width="68px">
                                    <el-form-item label="产品类别" prop="productType">
                                        <el-select label-width="68px" v-model="queryProductParams.productType"
                                            placeholder="请选择产品类别" clearable @keyup.enter.native="handleQueryProduct">
                                            <el-option
                                                v-for="           dict            in            dict.type.product_type           "
                                                :key="dict.value" :label="dict.label" :value="dict.value" />
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item label="产品编号" prop="productNo">
                                        <el-input v-model="queryProductParams.productNo" label-width="68px"
                                            placeholder="请输入产品编号" clearable @keyup.enter.native="handleQueryProduct" />
                                    </el-form-item>
                                    <el-form-item label="产品名称" prop="productName">
                                        <el-input v-model="queryProductParams.productName" placeholder="请输入产品名称"
                                            clearable @keyup.enter.native="handleQueryProduct" />
                                    </el-form-item>
                                    <el-form-item label="产品状态" prop="productStatus">
                                        <el-select v-model="queryProductParams.productStatus" placeholder="请选择产品状态"
                                            clearable @keyup.enter.native="handleQueryProduct">
                                            <el-option
                                                v-for="           dict            in            dict.type.product_status           "
                                                :key="dict.value" :label="dict.label" :value="dict.value" />
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item>
                                        <el-button type="primary" icon="el-icon-search" size="mini"
                                            @click="handleQueryProduct">搜索</el-button>
                                        <el-button icon="el-icon-refresh" size="mini"
                                            @click="resetQueryProduct">重置</el-button>
                                        <el-button type="primary" size="mini" @click="saveProduct">确定</el-button>
                                    </el-form-item>
                                </el-form>
                                <el-table v-loading="loading" size="mini" height="450" :row-style="{ height: '30px' }"
                                    border :cell-style="{ padding: '0px' }" :data="qualificationList" ref="tableProduct"
                                    @selection-change="handleSelectionChangeProduct">
                                    <el-table-column type="selection" width="45" align="center" />
                                    <el-table-column label="序号" type="index" :index="indexMethod" />
                                    <el-table-column label="产品类别" align="center" prop="productType">

                                        <template slot-scope="scope">
                                            <dict-tag :options="dict.type.product_type"
                                                :value="scope.row.productType" />
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="产品编号" align="center" prop="productNo" />
                                    <el-table-column label="产品名称" align="center" prop="productName" />
                                    <el-table-column label="定价范围" align="center" prop="productPrice" />
                                </el-table>
                                <pagination v-show="total2 > 0" :total="total2" :page.sync="queryProductParams.pageNum"
                                    :limit.sync="queryProductParams.pageSize" @pagination="getProductList" />
                            </el-col>
                        </el-row>
                    </el-dialog>

                    <!-- 资质产品选择界面 結束 -->


                    <!-- 合同产品选择界面 -->
                    <el-dialog :title="titleContractProduct" :visible.sync="openContractProduct" width="800px"
                        append-to-body>
                        <el-row>
                            <el-col>
                                <el-form :model="queryContractProductParams" ref="queryContractProductForm" size="small"
                                    :inline="true" v-show="showSearch" label-width="70px">
                                    <el-form-item label="产品编号" prop="productNumber">
                                        <el-input v-model="queryContractProductParams.productNumber"
                                            placeholder="请输入产品编号" clearable
                                            @keyup.enter.native="handleQueryContractProduct" style="width:172px" />
                                    </el-form-item>
                                    <el-form-item label="产品名称" prop="productName">
                                        <el-input v-model="queryContractProductParams.productName" placeholder="请输入产品名称"
                                            clearable @keyup.enter.native="handleQueryContractProduct"
                                            style="width:172px" />
                                    </el-form-item>
                                    <el-form-item label="产品类别" prop="productCategory">
                                        <el-select style="width:172px"
                                            v-model="queryContractProductParams.productCategory" placeholder="请选择产品类别"
                                            clearable @keyup.enter.native="handleQueryContractProduct">
                                            <el-option
                                                v-for="           dict            in            dict.type.product_type           "
                                                :key="dict.value" :label="dict.label" :value="dict.value" />
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item>
                                        <el-button type="primary" icon="el-icon-search" size="mini"
                                            @click="handleQueryContractProduct">搜索</el-button>
                                        <el-button icon="el-icon-refresh" size="mini"
                                            @click="resetQueryContractProduct">重置</el-button>
                                        <el-button type="primary" size="mini"
                                            @click="saveContractProduct">确定</el-button>
                                    </el-form-item>
                                </el-form>
                                <el-table v-loading="loading" height="400" :row-style="{ height: '30px' }" border
                                    :cell-style="{ padding: '0px' }" :data="contractProductList"
                                    ref="tableContractProduct" @selection-change="handleSelectionChangeContractProduct">
                                    <el-table-column type="selection" width="45" align="center" />
                                    <el-table-column label="序号" type="index" :index="indexMethod" align="center" />
                                    <el-table-column label="产品类别" align="center" prop="productCategory">

                                        <template slot-scope="scope">
                                            <dict-tag :options="dict.type.product_type"
                                                :value="scope.row.productCategory" />
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="产品编号" align="center" prop="productNumber" />
                                    <el-table-column label="产品名称" align="center" prop="productName" />
                                    <el-table-column label="费用" align="center" prop="pricingRange" />
                                </el-table>
                                <pagination v-show="total3 > 0" :total="total3"
                                    :page.sync="queryContractProductParams.pageNum"
                                    :limit.sync="queryContractProductParams.pageSize"
                                    @pagination="getContractProductList" />
                            </el-col>
                        </el-row>
                    </el-dialog>
                    <!-- 合同产品选择界面 結束 -->

                    <!-- 合同选择界面 -->
                    <el-dialog :title="titleContract" :visible.sync="openContract" width="1000px" append-to-body>
                        <el-row>
                            <el-col :span="24">
                                <el-form :model="queryContractParams" ref="queryContractForm" size="small"
                                    :inline="true" v-show="showSearch" label-width="68px">
                                    <el-form-item label="合同名称" prop="contractName">
                                        <el-input v-model="queryContractParams.contractName" placeholder="请输入合同名称"
                                            clearable @keyup.enter.native="handleQuery" />
                                    </el-form-item>
                                    <el-form-item label="签订时间">
                                        <el-date-picker v-model="dateRange" style="width: 240px"
                                            value-format="yyyy-MM-dd" type="daterange" range-separator="-"
                                            start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
                                    </el-form-item>

                                    <el-form-item>
                                        <el-button type="primary" icon="el-icon-search" size="mini"
                                            @click="handleQueryContract">搜索</el-button>
                                        <el-button icon="el-icon-refresh" size="mini"
                                            @click="resetQueryContract">重置</el-button>
                                        <el-button type="primary" size="mini" @click="saveContract">确定</el-button>
                                    </el-form-item>
                                </el-form>
                                <el-table class="table-style" v-loading="loading" ref="tableContract" height="400"
                                    :row-style="{ height: '30px' }" border :cell-style="{ padding: '0px' }"
                                    :data="contractList" @selection-change="handleSelectionChangeContract">
                                    <el-table-column type="selection" width="55" align="center" />
                                    <!-- <el-table-column v-show="true" label="合同id" align="center" prop="contractId" width="180"
                            :show-overflow-tooltip="true" /> -->
                                    <el-table-column label="序号" type="index" align="center" prop="index"
                                        :index="indexMethodContractList" width="60"></el-table-column>
                                    <el-table-column label="合同名称" align="center" prop="contractName"
                                        :show-overflow-tooltip="true" width="140" />
                                    <el-table-column label="合同金额" align="center" prop="contractAmount"
                                        :show-overflow-tooltip="true" width="80" />
                                    <el-table-column label="产品名称" align="center" prop="productName"
                                        :show-overflow-tooltip="true" width="100" />
                                    <el-table-column label="签订时间" align="center" prop="signingTime"
                                        :show-overflow-tooltip="true" width="100">

                                        <template slot-scope="scope">
                                            <span>{{ parseTime(scope.row.signingTime, '{y}-{m}-{d}') }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="结束时间" align="center" prop="endTime"
                                        :show-overflow-tooltip="true" width="100">

                                        <template slot-scope="scope">
                                            <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="销售人员" align="center" prop="salespersonName" width="120" />
                                    <el-table-column label="客户名称" align="center" prop="enterpriseName" width="160"
                                        :show-overflow-tooltip="true" />
                                    <el-table-column label="客户联系人" align="center" prop="customerContact" width="100"
                                        :show-overflow-tooltip="true" />
                                    <el-table-column label="联系电话" align="center" prop="telephone"
                                        :show-overflow-tooltip="true" width="100" />
                                    <!-- <el-table-column label="合同扫描件" align="center" prop="url" />
                                        <template slot-scope="scope">
                                            <div v-if="scope.row.url != null && scope.row.url != '' && (scope.row.url).indexOf('.pdf')
                                                !== -1" @click="handlePictureCardPreviewPdf(scope.row.url)">
                                                <pdf :src="scope.row.url"></pdf>
                                            </div>
                                            <div class="block" v-else>
                                                <el-image style="width: 50px; height: 50px" :src="scope.row.url"
                                                    @click="handlePictureCardPreview(scope.row.url)">
                                                    <div slot="error" class="image-slot">
                                                        <i class="el-icon-picture-outline"></i>
                                                    </div>
                                                </el-image>
                                            </div>
                                        </template>
                                    </el-table-column> -->
                                    <el-table-column label="状态" align="center" prop="state">

                                        <template slot-scope="scope">
                                            <dict-tag :options="dict.type.contract_state" :value="scope.row.state"
                                                :class="{ 'add-class': scope.row.state === '0', 'review-class': scope.row.state === '1', 'agree-class': scope.row.state === '2', 'cancel-class': scope.row.state === '3', }" />
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="创建人" align="center" prop="creationName" width="140" />
                                    <el-table-column label="创建时间" align="center" prop="creationTime"
                                        :show-overflow-tooltip="true" width="100">

                                        <template slot-scope="scope">
                                            <span>{{ parseTime(scope.row.creationTime, '{y}-{m}-{d}') }}</span>
                                        </template>
                                    </el-table-column>

                                </el-table>
                                <pagination v-show="total1 > 0" :total="total1" :page.sync="queryContractParams.pageNum"
                                    :limit.sync="queryContractParams.pageSize" @pagination="getContractList" />
                            </el-col>
                        </el-row>
                    </el-dialog>
                    <!-- 合同选择界面 結束 -->

                    <!-- 项目查看界面 -->
                    <el-dialog :title="titlePojectAll" :visible.sync="openProjectAll" width="1000px" append-to-body>
                        <el-row>
                            <!-- <el-col :span="5">
                              <MainType :typeCode="typeProjectCode" @getNode="getNode"></MainType>
                            </el-col> -->
                            <el-col :span="25">
                                <!-- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true"
                                    v-show="showSearch" label-width="68px">
                                    <el-form-item label="项目编号" prop="projectNumber">
                                        <el-input v-model="queryParams.projectNumber" style="width:165px"
                                            placeholder="请输入项目编号" clearable @keyup.enter.native="handleQuery" />
                                    </el-form-item>
                                    <el-form-item label="项目名称" prop="projectName">
                                        <el-input v-model="queryParams.projectName" style="width:170px"
                                            placeholder="请输入项目名称" clearable @keyup.enter.native="handleQuery" />
                                    </el-form-item>
                                    <el-form-item label="开始时间" prop="startTime">
                                        <el-date-picker clearable style="width:155px" v-model="queryParams.startTime"
                                            type="date" value-format="yyyy-MM-dd" placeholder="请选择开始时间">
                                        </el-date-picker>
                                    </el-form-item>
                                    <el-form-item label="结束时间" prop="endTime">
                                        <el-date-picker clearable style="width:155px" v-model="queryParams.endTime"
                                            type="date" value-format="yyyy-MM-dd" placeholder="请选择结束时间">
                                        </el-date-picker>
                                    </el-form-item>
                                    <el-form-item>
                                        <el-button type="primary" icon="el-icon-search" size="mini"
                                            @click="handleQuery">搜索</el-button>
                                        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                                    </el-form-item>
                                </el-form> -->
                                <el-table v-loading="loading" height="400" :row-style="{ height: '30px' }" border
                                    :cell-style="{ padding: '0px' }" :data="projectInfoList">
                                    <el-table-column type="selection" width="55" align="center" />
                                    <el-table-column label="序号" type="index" align="center" prop="index"
                                        :index="indexMethod" />
                                    <el-table-column label="项目编号" align="center" prop="projectNumber" width="110"
                                        :show-overflow-tooltip="true" />
                                    <el-table-column label="项目名称" align="center" prop="projectName" width="130"
                                        :show-overflow-tooltip="true" />
                                    <el-table-column label="项目负责人" align="center" prop="projectLeader" width="120"
                                        :show-overflow-tooltip="true" />
                                    <el-table-column label="计划开始时间" align="center" prop="startTime" width="100"
                                        :show-overflow-tooltip="true" />
                                    <el-table-column label="计划结束时间" align="center" prop="endTime" width="100"
                                        :show-overflow-tooltip="true" />
                                    <el-table-column label="状态" align="center" prop="state">

                                        <template slot-scope="scope">
                                            <dict-tag :options="dict.type.project_status" :value="scope.row.state" />
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="创建人" align="center" prop="creationName"
                                        :show-overflow-tooltip="true" width="120" />
                                    <el-table-column label="创建时间" align="center" prop="creationTime" width="100">

                                        <template slot-scope="scope">
                                            <span>{{ parseTime(scope.row.creationTime, '{y}-{m}-{d}') }}</span>
                                        </template>
                                    </el-table-column>
                                </el-table>
                                <pagination v-show="totalProject > 0" :total="totalProject"
                                    :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                                    @pagination="getProjectListAll" />
                            </el-col>
                        </el-row>
                    </el-dialog>
                    <!-- 项目查看界面 結束 -->
                </el-form>
                <div style="text-align: center;margin-top:20px">
                    <el-button type="primary" @click="submitForm" v-if="opt != 'details'">保 存</el-button>
                    <el-button @click="cancel">关 闭</el-button>
                </div>
            </el-tab-pane>
            <el-tab-pane label="评审信息" name="four" :disabled="isShowTab">
                <div style="text-align: center;">
                    <div>
                        <el-form ref="formReview" :model="formReview" :inline="true" :rules="reviewRules">
                            <el-row v-if="isSave" style="line-height: 1px;">
                                <el-col :span="7" style="margin-left: 345px;">
                                    <el-form-item label="评审人" prop="reviewer" label-width="110px">
                                        <el-input v-model="formReview.reviewer" placeholder="请选择评审人" readonly="readonly"
                                            style="width: 207px;" />
                                    </el-form-item>
                                    <el-input v-model="formReview.reviewerId" type="hidden" />
                                </el-col>
                                <el-col :span="1">
                                    <el-button style="margin-left: -20px;" type="primary"
                                        @click="selectReviewUser">选择</el-button>
                                </el-col>
                            </el-row>
                        </el-form>
                        <el-row>
                            <el-table v-loading="loading" :data="reviewList">
                                <el-table-column label="评审人" align="center" prop="reviewer" width="180" />
                                <el-table-column label="评审结果" align="center" prop="reviewResult" width="180">

                                    <template slot-scope="scope">
                                        <dict-tag :options="dict.type.contract_review_result"
                                            :value="scope.row.reviewResult" />
                                    </template>
                                </el-table-column>
                                <el-table-column label="评审意见" align="center" prop="reviewComments" />
                                <el-table-column label="评审时间" align="center" prop="reviewTime" width="180">

                                    <template slot-scope="scope">
                                        <span>{{ parseTime(scope.row.reviewTime, '{y}-{m}-{d}') }}</span>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </el-row>
                        <div style="text-align: center;margin-top: 15px;">
                            <el-button type="primary" @click="submitReviewForm" v-if="isSave">保 存</el-button>
                            <el-button @click="cancel">关 闭</el-button>
                        </div>
                    </div>

                </div>

            </el-tab-pane>

        </el-tabs>
        <select-user ref="select" :type="userType" :sign="sign" @ok="selectUser"></select-user>
        <el-dialog :title="titleEnterprise" :visible.sync="openEnterprise" width="1000px" append-to-body>
            <el-row>
                <el-col :span="24">
                    <el-form :model="queryEnterpriseParams" ref="queryFormEnterprise" size="small" :inline="true"
                        v-show="showSearch" label-width="100px">
                        <el-form-item label="企业名称" prop="enterpriseName">
                            <el-input v-model="queryEnterpriseParams.enterpriseName" placeholder="请输入企业名称" clearable
                                @keyup.enter.native="handleQueryEnterprise" />
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" icon="el-icon-search" size="mini"
                                @click="handleQueryEnterprise">搜索</el-button>
                            <el-button icon="el-icon-refresh" size="mini" @click="resetQueryEnterprise">重置</el-button>
                            <el-button type="primary" size="mini" @click="saveSelectEnterprise">确定</el-button>
                        </el-form-item>
                    </el-form>
                    <el-table ref="tableEnterprise" v-loading="loading" height="400" :row-style="{ height: '30px' }"
                        border :cell-style="{ padding: '0px' }" @selection-change="handleSelectionChangeEnterprise"
                        :data="infoList">
                        <el-table-column type="selection" width="45" align="center" />
                        <el-table-column label="企业名称" align="center" prop="enterpriseName" />
                        <el-table-column label="联系人" align="center" prop="contacts" />
                        <el-table-column label="联系电话" align="center" prop="telephone" show-overflow-tooltip="true" />
                    </el-table>
                    <pagination v-show="totalEnterprise > 0" :total="totalEnterprise"
                        :page.sync="queryEnterpriseParams.pageNum" :limit.sync="queryEnterpriseParams.pageSize"
                        @pagination="getEnterpriseList" />
                </el-col>
            </el-row>
        </el-dialog>
        <el-dialog title="填写费用" :visible.sync="addFeesOpen" width="400px" append-to-body>
            <el-form ref="formFees" :model="formFees" :inline="true" :rules="rulesFees">
                <el-form-item label="费用" prop="pricingRange" label-width="80px">
                    <el-input v-model="formFees.pricingRange" placeholder="请输入费用" />
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitFessForm">保 存</el-button>
                <el-button @click="cancelFees">关 闭</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import { listProjectInfo, listProjectInfoAll, getProjectInfo, delProjectInfo, addProjectInfo, updateProjectInfo } from "@/api/project/projectInfo";
import { listContractInfo } from "@/api/contract/info";
import { id } from "@/api/system/UUID";
import { listMethod, getMethod, delMethod, addMethod, updateMethod } from "@/api/project/method";
import { listType } from "@/api/maintype/type";
import SelectUser from "../../system/role/selectUser.vue";
import { listInfo, getInfo } from "@/api/enterprise/info";
import Treeselect from "@riophae/vue-treeselect";
import MainType from "@/components/MainType/index"
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import EnterpriseInfo from "../../enterprise/info/index.vue";
import { listProductInfo, getProductInfo, delProductInfo, addProductInfo, updateProductInfo } from "@/api/contract/productInfo";
import { listReviewInfo, getReviewInfo, delReviewInfo, addReviewInfo, updateReviewInfo } from "@/api/project/review";
import { listProjectProductInfo, getProjectProductInfo, delProjectProductInfoByProjectId, delProjectProductInfo, addProjectProductInfo, updateProjectProductInfo } from "@/api/project/projectProductInfo";
import { listQualification, getQualification, delQualification, addQualification, updateQualification, approveStatus } from "@/api/qualificationInfo/qualification";
export default {
    name: "Info",
    components: { Treeselect, SelectUser, MainType, EnterpriseInfo },
    dicts: ['business_classify', 'project_status', 'contract_state', 'customer_industry', 'business_state', 'tracking_stage', 'enterprise_records', 'product_type', 'product_status', 'customer_industry', 'administrative_area', 'qualification_resume_status', 'contract_review_result'],
    props: {
        opt: {
            type: String,
            default: ""
        },
        newMarkAs: {
            type: String,
            default: ""
        },
        classId: {
            type: String,
            default: ""
        },
        seas: {
            type: String,
            default: "0"
        },
        id: {
            type: String,
            default: ""
        },
        obj: {
            type: Object,
            default: null
        },
        //序号
        index: {
            type: Number,
            default: 0
        }
    },
    data() {

        var projectLeader = (rule, value, callback) => {
            if (!value) {
                return callback(new Error('项目负责人不能为空'));
            }
            return callback()
        };
        var reviewer = (rule, value, callback) => {
            if (!value) {
                return callback(new Error('评审人不能为空'));
            }
            return callback()
        };
        var enterpriseName = (rule, value, callback) => {
            if (this.radio == "2") {
                if (!value) {
                    return callback(new Error('客户名称不能为空'));
                }
            }

            return callback()
        };

        var contractName = (rule, value, callback) => {
            if (this.radio == "1") {
                if (!value) {
                    return callback(new Error('合同名称不能为空'));
                }
            }

            return callback()
        };
        return {
            queryEnterpriseParams: {
                pageNum: 1,
                pageSize: 15,
                enterpriseName: null,
                markAs: '1',
            },
            //收款方式
            queryPaymentParams: {
                pageNum: 1,
                pageSize: 15,
                paymentId: null,
                projectId: null,
                paymentName: null,
                amountCollected: null,
                estimatedCollectionTime: null
            },
            isBtn: true,
            addFeesOpen: false,
            formFees: {},
            enterpriseCode: "enterprise",
            typeProjectCode: 'project',
            formReview: {},
            isSave: true,
            dateRange: [],
            isTree: false,
            qualificationList: [],
            contractProductList: [],
            totalProject: 0,
            totalEnterprise: 0,
            total2: 0,
            total1: 0,
            total3: 0,
            openProjectAll: false,
            titleEnterprise: "客户选择",
            titlePojectAll: "项目查看",
            titleProduct: "产品选择",
            titleContractProduct: "合同产品选择",
            titleContract: "合同选择",
            openProduct: false,
            openEnterprise: false,
            openContractProduct: false,
            qualificationCode: "qualification",
            qualificationCode: "qualification",
            contractCode: 'contractInfo',
            //产品列表
            productInfoList: [],
            typeShow: true,
            typeShow2: false,
            radio: '1',
            readonly: true,
            checkCount: 0,
            isShowTab: true,
            UUID: '',
            userType: "1",
            optionData: null,
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],

            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            //行政区域
            options: null,
            // 企业信息表格数据
            recordsList: [],
            businessId: new Date().getTime(),
            // 弹出层标题
            title: "",
            sign: '1',
            honorShow: '0',
            // 是否显示弹出层
            open: false,
            queryContractForm: {},
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 15,
                state: null,
                projectName: null,
                projectNumber: null,
                startTime: null,
                endTime: null,
                attackTime: null,
                completeTime: null,

            },
            //资质产品查询参数
            queryProductParams: {
                pageNum: 1,
                pageSize: 15,
                classificationId: null,
                productId: null,
                productNo: null,
                productType: null,
                productNumber: null,
                productName: null,
                productPrice: null
            },
            //合同产品查询参数
            queryContractProductParams: {
                pageNum: 1,
                pageSize: 15,
                contractId: null,
                productId: null,
                productCategory: null,
                productNumber: null,
                productName: null,
                pricingRange: null
            },
            //合同查询参数
            queryContractParams: {
                pageNum: 1,
                pageSize: 15,
                //contractId: null,
                classificationId: null,
                contractName: null,
                relatedContractId: null,
                relatedContractName: null,
                contractAmount: null,
                signingTime: null,
                endTime: null,
                enterpriseId: null,
                enterpriseName: null,
                customerAddress: null,
                customerContact: null,
                telephone: null,
                salespersonId: null,
                salespersonName: null,
                additionalTerms: null,
                belongTo: null,
                creationId: null,
                creationName: null,
                creationTime: null,
                operateTime: null,
                operateId: null,
                departmentId: null,
                departmentName: null,
                organizationId: null,
                organizationName: null,
                state: null
            },
            queryReviewParams: {
                pageNum: 1,
                pageSize: 15,
                reviewId: null,
                projectId: null,
                reviewerId: null,
                reviewer: null,
                reviewComments: null,
                reviewTime: null,
                reviewResult: null
            },
            //产品查询参数
            queryProductListParams: {
                pageNum: 1,
                pageSize: 15,
                projectId: null,
                productId: null,
                productCategory: null,
                productNumber: null,
                productName: null,
                pricingRange: null
            },
            // 表单参数
            form: {
                creationName: this.$store.state.user.name,
                creationTime: this.parseTime(new Date(), '{y}-{m}-{d}'),
                classificationId: '650c44e1-b575-4b62-9d54-1ba9d1e8abb7',
                contractName: null
            },
            // 表单校验
            rules: {

                projectName: [
                    { required: true, message: "项目名称不能为空", trigger: "blur" },
                    { max: 50, message: '项目名称长度不能超过50', trigger: 'blur' }
                ],
                projectNumber: [
                    { required: true, message: "项目编号不能为空", trigger: "blur" },
                    { max: 100, message: '项目编号不能超过100字', trigger: 'blur' }
                ],
                consultAmount: [
                    //{ required: true, message: "预算金额不能为空", trigger: "blur" },
                    {
                        //pattern: /^[1-9]\d*$/,
                        //金额校验 保留两位小数
                        pattern: /^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/,
                        message: "请输入正确的金额，可保留两位小数",
                        trigger: "blur"
                    }
                ],
                elseAmount: [
                    //{ required: true, message: "预算金额不能为空", trigger: "blur" },
                    {
                        //pattern: /^[1-9]\d*$/,
                        //金额校验 保留两位小数
                        pattern: /^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/,
                        message: "请输入正确的金额，可保留两位小数",
                        trigger: "blur"
                    }
                ],
                projectLeader: [
                    { required: true, validator: projectLeader, trigger: "change" }
                ],
                contractName: [
                    { required: true, validator: contractName, trigger: "change" }
                ],
                enterpriseName: [
                    { required: true, validator: enterpriseName, trigger: "change" }
                ],

                startTime: [
                    { required: true, message: "计划开始时间不能为空", trigger: "change" }
                ],
                endTime: [
                    { required: true, message: "计划结束时间不能为空", trigger: "change" }
                ],
            },
            reviewRules: {
                reviewer: [
                    { required: true, validator: reviewer, trigger: "change" }
                ],
            },
            //复选框
            markAs: null,
            //选显卡默认选中
            activeName: 'first',
            //
            show: '',
            pId: "",
            //上传按钮隐藏
            isShow: true,
            productIds: [],
            productNames: [],
            productTypes: [],
            productCodes: [],
            productRanges: [],
            contractList: [],
            openContract: false,
            contractName: null,
            enterpriseName: null,
            enterpriseId: null,
            contractId: null,
            porjectid: null,
            reviewList: [],
            projectInfoList: [],
            eIds: [],
            eName: [],
            infoList: [],
            //收款方式
            tableData: [],

        };
    },
    watch: {
        obj(newVal) {
            this.form = newVal
            this.$forceUpdate();
        },
    },
    created() {
        this.getEnterpriseList();
        this.listType()
        this.getProjectProductList();
        this.getProjectListAll()
        //资质产品
        this.getProductList();
        //合同产品
        //this.getContractProductList();
        this.getContractList();
        let url = window.location.href;
        // 获取参数部分

        //新增
        if (this.opt == "add") {
            this.getId();

            if (this.classId != null) {
                this.form.classificationId = this.classId
            }
        }//编辑
        if (this.opt == "edit") {
            this.isShowTab = false
            this.bId = this.id;
            this.pId = this.id;
            this.handleUpdate(this.id)
        }
        if (this.opt == "details") {
            this.isBtn = false;
            this.handleUpdate(this.id)
            this.isSave = false;
            this.isShowTab = false
            this.pId = this.id;
            //     //this.form.administrativeArea = this.obj.areaName
            //     this.form = this.obj
            //     console.log(this.form)

            // }
        }
        this.getReviewList();
    },
    methods: {
        //费用填写---
        addFees(row) {
            this.resetFees();
            const id = row.id;
            console.log(row)
            if (this.radio == "2") {
                getProjectProductInfo(id).then(response => {
                    this.formFees = response.data;
                });
                this.addFeesOpen = true;
            }

        },
        submitFessForm() {
            this.$refs["formFees"].validate(valid => {
                if (valid) {
                    updateProjectProductInfo(this.formFees).then(response => {
                        this.$modal.msgSuccess("填写成功");
                        this.addFeesOpen = false;
                        this.getProjectProductList();
                    });
                }
            });
        },
        cancelFees() {
            this.addFeesOpen = false;
        },
        resetFees() {
            this.formFees = {
                id: null,
                contractId: null,
                productId: null,
                productCategory: null,
                productNumber: null,
                productName: null,
                pricingRange: null
            };
            this.resetForm("formFees");
        },
        //------
        dateOptions(time) {
            return time.getTime() < Date.now() - 24 * 60 * 60 * 1000
        },
        //收款方式
        addProjectPayment() {
            var tableList = this.tableData;
            var num = 0;
            for (var i = 0; i < tableList.length; i++) {
                if (tableList[i].paymentName == '' || tableList[i].paymentName == null || tableList[i].amountCollected == '' || tableList[i].amountCollected == null || tableList[i].estimatedCollectionTime == '' || tableList[i].estimatedCollectionTime == null) {
                    num++;
                }
            }
            if (num > 0) {
                this.$message.error('请先填写好收款方式！');
            } else {
                this.tableData.push({
                    indexTwo: tableList.length + 1,
                    paymentId: this.guid(),
                    projectId: '',
                    paymentName: '',
                    amountCollected: '',
                    estimatedCollectionTime: ''
                })
            }
        },
        delContractListInfo(row) {
            this.tableData = this.tableData.filter(data => data.paymentId !== row.paymentId)
        },
        //客户选择界面
        enterprise() {
            this.openEnterprise = true;
            this.$refs.tableEnterprise.clearSelection();
        },
        getReviewList() {
            this.loading = true;
            this.queryReviewParams.projectId = this.pId;
            listReviewInfo(this.queryReviewParams).then(response => {
                this.reviewList = response.rows;
                this.loading = false;
            });
        },
        selectReviewUser() {
            this.userShow(3);
        },
        userShow(type) {
            this.show = type
            this.$refs.select.show();

        },
        //评审提交
        submitReviewForm() {
            this.$refs["formReview"].validate(valid => {
                if (valid) {
                    const reviewInfo = {
                        reviewId: this.guid(),
                        projectId: this.pId,
                        reviewerId: this.formReview.reviewerId,
                        reviewer: this.formReview.reviewer
                    }
                    addReviewInfo(reviewInfo).then(response => {
                        this.$modal.msgSuccess("新增成功");
                        this.open = false;
                        this.getReviewList();
                    });
                }
            });
        },
        //合同選擇界面列表
        getContractList() {
            this.loading = true;
            this.queryContractParams.state = 2//只查询已评审办结的合同
            listContractInfo(this.addDateRange(this.queryContractParams, this.dateRange)).then(response => {
                this.contractList = response.rows;
                console.log(response.rows)
                this.total1 = response.total;
                this.loading = false;
            });
        },
        //保存選擇的合同信息
        saveContract() {
            if (this.contractName == "" || this.contractName == null) {
                this.$modal.msgError("请选择合同！");
            } else {
                this.openContract = false
                this.form.contractName = ""
                this.form.enterpriseName = ""
                this.form.contractId = ""
                this.form.enterpriseId = this.enterpriseId.toString()
                this.$set(this.form, 'contractName', this.contractName)
                this.$set(this.form, 'enterpriseName', this.enterpriseName.toString())
            }
            //this.$set(this.form, 'contractId', this.contractId)

        },
        //打開合同選擇界面
        selectContract() {
            this.openContract = true;
        },
        //打開项目查看界面
        selectProjectAll() {
            this.openProjectAll = true;
        },

        //合同数据反显
        handleSelectionChangeContract(selection) {
            // if (selection.length > 1) {
            //     this.$refs.table.clearSelection();
            //     this.$refs.table.toggleRowSelection(selection[0], false);
            // }
            if (selection.length > 1) {
                this.$refs.tableContract.clearSelection(); // 清空所有选择
                this.$refs.tableContract.toggleRowSelection(selection.pop()); // 设置选择项
            } else {
                this.contractId = selection.map(item => item.contractId)//單選
                this.contractName = selection.map(item => item.contractName)
                this.enterpriseId = selection.map(item => item.enterpriseId)
                this.enterpriseName = selection.map(item => item.enterpriseName)
                // this.single = selection.length !== 1
                // this.multiple = !selection.length
            }
            // this.contractId = selection[0].contractId//單選
            // this.contractName = selection[0].contractName
            // this.enterpriseId = selection[0].enterpriseId
            // this.enterpriseName = selection[0].enterpriseName
        },

        //合同产品
        getContractProductList() {
            this.loading = true;
            if (this.contractId!==null){
              this.queryContractProductParams.contractId = this.contractId.toString()
            }else {
              this.queryContractProductParams.contractId = this.form.contractId.toString()
            }
            listProductInfo(this.queryContractProductParams).then(response => {
                this.contractProductList = response.rows;
                this.total3 = response.total;
                this.loading = false;
            });
        },
        //产品选择界面列表
        getProductList() {
            this.loading = true;
            //所有产品
            listQualification(this.queryProductParams).then(response => {
                this.qualificationList = response.rows;
                this.total2 = response.total;
                this.loading = false;
            });

        },
        //树点击事件
        getNode(data, node, obj) {
            this.queryParams.classificationId = data.id
            this.getProjectListAll()
        },
        //产品选择界面列表 主分類查詢
        getNodeProduct(data, node, obj) {
            this.queryProductParams.classificationId = data.id
            this.getProductList()
        },
        //合同選擇界面列表 主分類查詢
        getContractNode(data, node, obj) {
            this.queryContractParams.classificationId = data.id;
            //this.classId = data.id;
            //this.getList()
        },
        /** 查询所有项目信息列表 */
        getProjectListAll() {
            this.loading = true;
            listProjectInfoAll(this.queryParams).then(response => {
                this.projectInfoList = response.rows;
                this.totalProject = response.total;
                this.loading = false;
            });
        },
        //资质产品选择界面列表 重置操作
        resetQueryProduct() {
            this.queryProductParams.classificationId = null
            this.queryProductParams.productStatus = null
            this.queryProductParams.productNo = null
            this.queryProductParams.productType = null
            this.queryProductParams.productName = null
            //this.resetProduct();
            this.handleQueryProduct();
        },
        //资质产品选择界面列表 查询操作
        handleQueryProduct() {
            this.queryProductParams.pageNum = 1;
            this.getProductList();
        },

        //合同选择界面列表 重置操作
        resetQueryContract() {
            //this.resetContractProduct();
            this.dateRange = [];
            this.queryContractParams.contractName = null
            this.handleQueryContract();
        },
        //合同选择界面列表 查询操作
        handleQueryContract() {
            this.queryContractParams.pageNum = 1;
            this.getContractList();
        },
        //合同产品选择界面列表 重置操作
        resetQueryContractProduct() {
            //this.resetContractProduct();
            this.queryContractProductParams.productNumber = null
            this.queryContractProductParams.productCategory = null
            this.queryContractProductParams.productName = null
            this.handleQueryContractProduct();
        },
        //合同产品选择界面列表 查询操作
        handleQueryContractProduct() {
            this.queryContractProductParams.pageNum = 1;
            this.getContractProductList();
        },
        //保存选择的资质產品信息
        saveProduct() {
            if (this.opt == "add") {
                this.porjectid = this.UUID
            } else {
                this.porjectid = this.id
            }

            const productInfo = {
                projectId: this.porjectid,
                productId: this.productIds.toString(),
                productCategory: this.productTypes.toString(),
                productNumber: this.productCodes.toString(),
                productName: this.productNames.toString(),
                pricingRange: "0"
            }
            if (this.productIds.toString() == "" || this.productIds.toString() == null) {
                this.$modal.msgError("请选择资质产品！");
            } else {
                addProjectProductInfo(productInfo).then(response => {
                    this.$modal.msgSuccess("新增资质产品成功")
                    this.openProduct = false;
                    this.getProjectProductList();
                });
            }

        },

        //保存选择的合同产品信息
        saveContractProduct() {
            if (this.opt == "add") {
                this.porjectid = this.UUID
            } else {
                this.porjectid = this.id
            }

            const productInfo = {
                projectId: this.porjectid,
                productId: this.productIds.toString(),
                productCategory: this.productTypes.toString(),
                productNumber: this.productCodes.toString(),
                productName: this.productNames.toString(),
                pricingRange: this.productRanges.toString()
            }
            if (this.productIds.toString() == "" || this.productIds.toString() == null) {
                this.$modal.msgError("请选择合同产品！");
            } else {
                addProjectProductInfo(productInfo).then(response => {
                    this.$modal.msgSuccess("新增合同产品成功")
                    this.openContractProduct = false;
                    this.getProjectProductList();
                });
            }

        },

        //刪除已保存的項目產品
        handleDeleteProduct(row) {
            const ids = row.id || this.ids;
            this.$modal.confirm('是否确认删除产品名称为"' + row.productName + '"的数据信息？').then(function () {
                return delProjectProductInfo(ids);
            }).then(() => {
                this.getProjectProductList();
                this.$modal.msgSuccess("删除成功");
            }).catch(() => { });
        },


        //打開產品選擇界面
        selectProduct() {
            if (this.radio == "1") {
                //alert(this.contractId)
                if (this.contractId == null && this.form.contractId == null) {
                    this.$modal.msgError("请先选择合同，再选择产品！");
                } else {
                    this.getContractProductList();
                    this.openContractProduct = true;
                    this.openProduct = false;
                }

            } else if (this.radio == "2") {
                this.openProduct = true;
                this.openContractProduct = false;
            }

        },

        //资质产品 数据反显
        handleSelectionChangeProduct(selection) {
            this.productIds = selection.map(item => item.id)
            this.productNames = selection.map(item => item.productName)
            this.productCodes = selection.map(item => item.productNo)
            this.productTypes = selection.map(item => item.productType)
            this.productRanges = selection.map(item => item.productPrice)
            // this.single = selection.length !== 1
            // this.multiple = !selection.length
        },
        //合同产品 数据反显
        handleSelectionChangeContractProduct(selection) {
            this.productIds = selection.map(item => item.id)
            this.productNames = selection.map(item => item.productName)
            this.productCodes = selection.map(item => item.productNumber)
            this.productTypes = selection.map(item => item.productCategory)
            this.productRanges = selection.map(item => item.pricingRange)
            // this.single = selection.length !== 1
            // this.multiple = !selection.length
        },
        //查询选择的产品信息列表 根据項目id查詢
        getProjectProductList() {
            this.loading = true;
            //this.queryProductParams.projectId =this.id
            if (this.opt == "add") {
                this.queryProductParams.projectId = this.UUID
                //this.bId = this.form.projectId;
            } else {
                this.queryProductParams.projectId = this.id
            }
            listProjectProductInfo(this.queryProductParams).then(response => {
                this.productInfoList = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
        //立项方式点击事件
        handleRadioChange(value) {

            if (value == "2") {//产品
                listProjectProductInfo(this.queryProductParams).then(response => {
                    if (response.total > 0) {
                        this.$modal.confirm('立项方式更改为"产品"将会把已保存的合同产品删除，是否确认修改并重新选择资质产品和客户？').then(function () {
                            return delProjectProductInfoByProjectId(response.rows[0].projectId)
                        }).then(() => {
                            this.eIds = ""
                            this.productIds = ""
                            this.form.enterpriseName = ""
                            this.form.contractName = ""
                            this.typeShow = false
                            this.typeShow2 = true
                            this.radio = "2"
                            this.$modal.msgSuccess("删除成功");
                            this.getProjectProductList();
                        }).catch(() => {
                            this.radio = "1"
                        });
                    } else {
                        //alert(this.form.enterpriseName)
                        if (this.form.enterpriseName == undefined || this.form.enterpriseName == "" || this.form.enterpriseName == null) {
                            this.typeShow = false
                            this.typeShow2 = true
                            this.radio = "2"
                        } else {
                            this.$modal.confirm('立项方式更改为"产品"会清除当前合同信息，是否确认修改？').then(function () {
                            }).then(() => {
                                this.form.enterpriseName = ""
                                this.form.enterpriseId = ""
                                this.form.contractId = ""
                                this.form.contractName = ""
                                this.typeShow = false
                                this.typeShow2 = true
                                this.radio = "2"
                            }).catch(() => {
                                this.radio = "1"
                            });

                        }
                    }
                });
            } else if (value == "1") {//合同
                listProjectProductInfo(this.queryProductParams).then(response => {
                    if (response.total > 0) {
                        this.$modal.confirm('立项方式更改为"合同"将会把已保存的资质产品删除，是否确认修改并重新选择合同以及产品？').then(function () {
                            return delProjectProductInfoByProjectId(response.rows[0].projectId)
                        }).then(() => {
                            this.eIds = ""
                            this.productIds = ""
                            this.form.enterpriseName = ""
                            this.form.contractName = ""
                            this.typeShow = true
                            this.typeShow2 = false
                            this.radio = "1"
                            this.$modal.msgSuccess("删除成功");
                            this.getProjectProductList();
                        }).catch(() => {
                            this.radio = "2"
                        });
                    } else {
                        if (this.form.enterpriseName == undefined || this.form.enterpriseName == "" || this.form.enterpriseName == null) {
                            this.typeShow = true
                            this.typeShow2 = false
                            this.radio = "1"
                        } else {
                            this.$modal.confirm('立项方式更改为"合同"会清除当前客户信息，是否确认修改？').then(function () {
                            }).then(() => {
                                this.form.enterpriseName = ""
                                this.form.enterpriseId = ""
                                this.form.contractId = ""
                                this.form.contractName = ""
                                this.typeShow = true
                                this.typeShow2 = false
                                this.radio = "1"
                            }).catch(() => {
                                this.radio = "2"
                            });

                        }
                    }
                });

            }
        },

        getFile(data) {
            //console.log(JSON.stringify(data))
        },
        // 取消按钮
        cancel() {
            this.open = false;
            this.reset();
            this.$emit('change');
        },
        // 表单重置
        reset() {
            this.form = {
                projectId: null,
                classificationId: null,
                projectNumber: null,
                projectName: null,
                contractName: null,
                startTime: null,
                endTime: null,
                attackTime: null,
                completeTime: null,
            };
            this.resetForm("form");
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getProjectListAll();
        },

        //--客户选择开始---///
        /** 客户选择重置按钮操作 */
        resetQueryEnterprise() {
            this.resetForm("queryFormEnterprise");
            this.handleQueryEnterprise();
        },
        /** 搜索按钮操作 */
        handleQueryEnterprise() {
            this.queryEnterpriseParams.pageNum = 1;
            this.getEnterpriseList();
        },
        getEnterpriseList() {
            this.loading = true;
            listInfo(this.queryEnterpriseParams).then(response => {
                this.infoList = response.rows;
                this.totalEnterprise = response.total;
                this.loading = false;
            });
        },
        getNodeEnterprise(data, node, obj) {
            this.queryEnterpriseParams.classificationId = data.id
            this.getEnterpriseList()
        },
        //客户确定保存
        saveSelectEnterprise() {
            //alert("产品选择客户")
            if (this.eIds.toString() == "" || this.eIds.toString() == null) {
                this.$modal.msgError("请选择客户！");
            } else {
                if (this.radio == "1") {
                    this.$set(this.form, 'contractEnterpriseName', this.eName.toString())
                } else {
                    this.$set(this.form, 'enterpriseName', this.eName.toString())
                }
                this.$set(this.form, 'enterpriseId', this.eIds.toString())
                this.openEnterprise = false
            }
        },
        //客户反选
        handleSelectionChangeEnterprise(selection) {
            if (selection.length > 1) {
                this.$refs.tableEnterprise.clearSelection(); // 清空所有选择
                this.$refs.tableEnterprise.toggleRowSelection(selection.pop()); // 设置选择项
            } else {
                this.eIds = selection.map(item => item.enterpriseId)
                this.eName = selection.map(item => item.enterpriseName)
                // this.single = selection.length !== 1
                // this.multiple = !selection.length
            }
        },
        // handlesubmit(row) {
        //     row.projectId = this.form.projectId
        //     addRecords(row).then(response => {
        //         this.$modal.msgSuccess("保存成功");
        //     });
        // },
        indexMethod(index) {
            return (this.queryProductParams.pageNum - 1) * this.queryProductParams.pageSize + index + 1;
        },
        indexMethodList(index) {
            return (this.queryProductListParams.pageNum - 1) * this.queryProductListParams.pageSize + index + 1;
        },
        indexMethodContractList(index) {
            return (this.queryContractParams.pageNum - 1) * this.queryContractParams.pageSize + index + 1;
        },
        selectUser(userId,userName, phone, position, nickName) {
            if (this.show == '2') {//评审人
                this.$set(this.form, 'reviewer', nickName)
                this.$set(this.form, 'reviewerId', userId)
            } else if (this.show == '1') {//负责人
                this.$set(this.form, 'projectLeader', nickName)
                this.$set(this.form, 'projectLeaderId', userId)
            } else if (this.show == '3') {
                this.$set(this.formReview, 'reviewer', nickName)
                this.$set(this.formReview, 'reviewerId', userId)
            }

        },
        //获取树节点数据
        listType() {
            listType({ typeCode: 'project' }).then(res => {
                this.optionData = res.data;
            })
        },
        selectOpen(type) {
            this.show = type
            this.$refs.select.show();
        },
        normalizer(node) {
            if (node.children && !node.children.length) {
                delete node.children;
            }
            return {
                id: node.areaId,
                label: node.areaName,
                isDisabled: node.parentId == '000000' ? true : false,
                children: node.list.length > 0 ? node.list : 0,

            }
        },
        /** 修改按钮操作 */
        handleUpdate(id) {
            this.reset();
            getProjectInfo(id).then(response => {
                console.log(response)
                this.radio = response.data.projectType
                if (response.data.projectType == "2") {
                    this.typeShow2 = true
                    this.typeShow = false
                } else {
                    this.typeShow2 = false
                    this.typeShow = true
                }
                this.form = response.data;
            });
            this.queryPaymentParams.projectId = id;
            listMethod(this.queryPaymentParams).then(response => {
                this.tableData = response.rows;
            });
        },
        /** 提交按钮 */
        submitForm() {
            var amount = /^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/;
            //this.checkCount=1;
            if (new Date(this.form.endTime).getTime() < new Date(this.form.startTime).getTime()) {
                this.$message.error('计划开始时间不能大于计划完成时间！');
                return;
            }
            if (this.opt == "add" || this.opt == "edit") {
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        var tableList = this.tableData;
                        if (tableList.length == 0) {
                            this.$message.error('请添加收款方式！');
                            return;
                        }
                        for (var i = 0; i < tableList.length; i++) {
                            if (tableList[i].paymentName == '' || tableList[i].paymentName == null || tableList[i].amountCollected == '' || tableList[i].amountCollected == null || tableList[i].estimatedCollectionTime == '' || tableList[i].estimatedCollectionTime == null) {
                                this.$message.error('请填写的完整收款信息！');
                                return;
                            }
                            if (!amount.test(tableList[i].amountCollected)) {
                                this.$message.error('请输入正确的收款金额，可保留两位小数！');
                                return;
                            }
                        }

                        if (this.opt == "add") {

                            this.form.projectId = this.UUID
                            this.bId = this.form.projectId;
                            this.queryProductParams.projectId = this.UUID
                            this.form.projectType = this.radio
                            if (this.radio == "2") {
                                this.form.contractId = null
                                this.form.contractName = null
                            } else {
                                this.form.contractId = this.contractId.toString()
                                this.form.contractName = this.contractName.toString()
                            }
                        } else {
                            this.form.projectId = this.id
                            this.queryProductParams.projectId = this.id
                        }
                        this.form["projectPaymentMethods"] = this.tableData;
                        const data = this.form;
                        if (this.radio == "2") {
                            listProjectProductInfo(this.queryProductParams).then(response => {
                                if (response.total == 0) {
                                    this.$message.error('没有添加产品信息，请点击选择产品按钮进行添加操作！');
                                    return;
                                } else {
                                    updateProjectInfo(data).then(response => {
                                        this.isShowTab = false
                                        this.$modal.msgSuccess("保存成功");

                                    });
                                }
                            });
                        } else {
                            updateProjectInfo(data).then(response => {
                                this.isShowTab = false
                                this.$modal.msgSuccess("保存成功");

                            });
                        }
                    }

                });
            }
        },
        getId() {
            this.UUID = this.guid()
            this.pId = this.UUID;
            this.form.projectId = this.UUID
            this.queryProductParams.projectId = this.UUID;//项目id
        },
        guid() {
            function S4() {
                return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
            }
            return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
        },
        // 表单重置
        reset() {
            this.form = {
                projectId: null,
                projectType: null,
                node: null,
                classificationId: null,
                projectNumber: null,
                projectName: null,
                contractId: null,
                contractName: null,
                projectLeaderId: null,
                projectLeader: null,
                executorId: null,
                executorName: null,
                startTime: null,
                endTime: null,
                attackTime: null,
                completeTime: null,
                state: null,
                operateTime: null,
                operateId: null,
                operateName: null,
                departmentId: null,
                departmentName: null,
                organizationId: null,
                organizationName: null,
                creationId: null,
                creationName: null,
                creationTime: null,
                belongTo: null,
                delFlag: null
            };
            this.resetForm("form");
        },
        handleClick(tab, event) {

            if (tab.name == 'four') {
                this.honorShow = 1
            }


        },

    }
};
</script>

<style scoped lang="scss">
.project-operate-container {
  overflow-y: auto;
  overflow-x: auto;
  padding: 16px;
  max-width: 100%;
  max-height: 80vh;
  box-sizing: border-box;
}

/* // ::v-deep .el-table .el-table__header-wrapper .el-checkbox {
//     display: none;
// } */
// .table-style /deep/ .el-table-column--selection.is.leaf .el-checkbox {
//     display: none;
// }

.cancel-class {
    color: red;
}

/* 修改为 */

.table-style::v-deep .el-table-column--selection.is.leaf .el-checkbox {
    display: none;
}
</style>
